"""
    create by IAmFiveHigh on 2024/6/14
"""


class LinkListQueue:
    class Node:
        def __init__(self, e):
            self.e = e
            self.next = None

    def __init__(self):
        self._size = 0
        self.head = None
        self.tail = None

    def get_size(self):
        return self._size

    def is_empty(self):
        return self._size == 0

    def enqueue(self, element):
        if self.is_empty():
            self.tail = self.Node(element)
            self.head = self.tail
        else:
            self.tail.next = self.Node(element)
            self.tail = self.tail.next
        self._size += 1

    def dequeue(self):
        if self.is_empty():
            print("队列为空")
            return None

        if self._size == 1:
            node = self.head
            self.head = None
            self.tail = None
            self._size -= 1
            return node.e
        else:
            node = self.head
            self.head = self.head.next
            node.next = None
            self._size -= 1
            return node.e


if __name__ == '__main__':
    l1 = [1, 2, 3, 4, 5]
    q1 = LinkListQueue()
    for e in l1:
        q1.enqueue(e)

    for i in range(len(l1)):
        print(q1.dequeue())
